package com.zhsm.fuxi.utils

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions

/**
 * Created by GuZhC on 2018/10/26.
 * describe:
 */
object GlideUtils {
    fun loadImage(context: Context, url: Any?, imageView: ImageView) {
        var options = RequestOptions()
                .centerCrop()
//                .placeholder(R.color.white) //占位图
//                .error(R.color.white)       //错误图
                .diskCacheStrategy(DiskCacheStrategy.ALL)
        Glide.with(context).load(url).apply(options).into(imageView)
    }

    fun loadImage(context: Context, url: String?, imageView: ImageView, errorImage: Int) {
        var options = RequestOptions()
                .centerCrop()
//                .placeholder(R.color.white) //占位图
                .error(errorImage)       //错误图
                .diskCacheStrategy(DiskCacheStrategy.ALL)
        Glide.with(context).load(url).apply(options).into(imageView)
    }

}